package org.acmclass.fatworm.test.plaintext;

public class Tag {

	public static final Tag TEST_CASE = new Tag("TEST_CASE");
	public static final Tag NEW_THREAD = new Tag("NEW_THREAD");
	public static final Tag UNORDERED_SELECT = new Tag("UN_ORDERED_SELECT");
	public static final Tag ORDERED_SELECT = new Tag("ORDERED_SELECT");

	private String str;

	private Tag(String str) {
		this.str = str;
	}

	public static Tag getTag(String s) {
		String[] parts = s.split("\\s+", 2);
		if (parts[0].equalsIgnoreCase("@" + TEST_CASE.str))
			return TEST_CASE;
		else if (parts[0].equalsIgnoreCase("@" + NEW_THREAD.str))
			return NEW_THREAD;
		else if (parts[0].equalsIgnoreCase("@" + UNORDERED_SELECT.str))
			return UNORDERED_SELECT;
		else if (parts[0].equalsIgnoreCase("@" + ORDERED_SELECT.str))
			return ORDERED_SELECT;
		return null;
	}

	public String toString() {
		return "@".concat(str);
	}
}
